<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List,cx.cx.pojo.Car" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.css"/>
<script src="js/jquery-3.4.1.js" type="text/javascript"></script>
<script src="js/bootstrap.js" type="text/javascript"></script>


</head>
<body>
<div class="container">
<table class="table table-bordered" id="tb">
   <tr>
   <div class="row">
      <th class="col-sm-4">车名</th>
      <th class="col-sm-1">上传时间</th>
      <th class="col-sm-1">里程</th>
      <th class="col-sm-2">排量</th>
      <th class="col-sm-1">变速箱</th>
      <th class="col-sm-1">价格</th>
      <th class="col-sm-2">操作</th>
     </div>
   </tr>
   
  <% List<Car> listCar = (List<Car>)session.getAttribute("list"); %>



 <% for(int i = 0; i < listCar.size(); i++){ %>
 <%-- 比较涂色 --%>
 	 
 	 
 	 <tr class="info" id="tr<%=(i +1) + ""%>">
 		<%-- 查询变色 --%>
 		<td><%=listCar.get(i).getCarName()%></td>
  		<td><%=listCar.get(i).getCarLoadtime()%></td>
   		<td><%=listCar.get(i).getMileage()%></td>
   		<td><%=listCar.get(i).getVolume()%></td>
   		<td><%=listCar.get(i).getGearbox()%></td>
   		<td><%=listCar.get(i).getPrice()%></td>
   		<td><button type="button" class="btn btn-primary" onclick="details(<%=listCar.get(i).getId() + ""%>)">修改</button>
   		<button type="button" class="btn btn-primary" style="margin-left:8px" onclick="deleteJobDetail(<%=listCar.get(i).getId() %>)">删除</button>
   		</td>
 	</tr>
 	
 <%} %>

   
</table>
</div>

<script>
// id接收传递的参数
function details(id){
	//alert(id)  get方式传参 url地址?name=value  url地址?name1=value1&name2=value2
	location.href="http://localhost:8080/car/Details?id=" + id
}


function del(id){
	location.href="http://localhost:8080/car/DelServlet?id=" + id
}

/* alert("haha");
if(confirm){
	alert("yi==");
	} */

	function deleteJobDetail(id){

		     if(window.confirm('你确定要删除吗')){
	               //alert(11)
		         location.href="http://localhost:8080/car/DelServlet?id=" + id

		           return true;

		      }else{

		          return false;
		      }
		  }
	
</script>


</body>
</html>